<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="入库单编号">
              <j-input placeholder="请输入入库单编号" v-model="queryParam.orderId"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="供货商单位">
              <j-input placeholder="请输入供货商单位" v-model="queryParam.salesPhone"></j-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="车辆状态">
                <j-input placeholder="请输入车辆状态" v-model="queryParam.ownerName"></j-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="6" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
              >重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a-button type="primary" @click="getInfo(record)">查看详情</a-button>
        </span>
        <span
          slot="filterDepositAttribute"
          slot-scope="depositAttribute"
        >{{ depositAttribute | filterDepositAttribute(depositAttribute) }}</span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <cxmOrderManager-modal ref="modalForm" @ok="modalFormOk"></cxmOrderManager-modal>
    <cxm-order-manager-info-modal ref="cxmOrderManagerInfoModal"></cxm-order-manager-info-modal>
  </a-card>
</template>

<script>
  import CxmOrderManagerModal from '../../../cxm/modules/CxmOrderManagerModal.vue'
  import CxmOrderManagerInfoModal from '../../../cxm/modules/CxmOrderManagerInfoModal.vue'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import moment from 'moment'
  import { USER_INFO } from '@/store/mutation-types'
  import Vue from 'vue'
  import { getAction } from '@/api/manage'

  export default {
    name: 'CarRefund',
    mixins: [JeecgListMixin],
    components: {
      CxmOrderManagerModal,
      CxmOrderManagerInfoModal,
      JInput,
      moment
    },
    data() {
      return {
        description: 'cxm-订单管理页面',
        visible: false,
        // 表头
        dataSources:[],
        columns: [
          {
            title: '退款日期',
            align: 'center',
            dataIndex: 'refundTime'
          },
          {
            title: '退款单编号',
            align: 'center',
            dataIndex: 'orderId'
          },
          {
            title: '退款项目',
            align: 'center',
            dataIndex: 'expenseName'
          },
          {
            title: '收款人',
            align: 'center',
            dataIndex: 'payer'
          },
          {
            title: '退款金额(元)',
            align: 'center',
            dataIndex: 'refunds',
            // scopedSlots: {
            //   customRender: 'filterDepositAttribute'
            // }
          },
          {
            title: '退款原因',
            align: 'center',
            dataIndex: 'refundReason'
          },
          {
            title: '原收据编号',
            align: 'center',
            dataIndex: 'id'
          },
          {
            title: '开票人',
            align: 'center',
            dataIndex: 'epositAmount'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],

        url: {
          list: '/sale/cxmSaleReceipt/list',
          delete: '/cxm/cxmOrderManager/delete',
          deleteBatch: '/cxm/cxmOrderManager/deleteBatch',
          exportXlsUrl: 'cxm/cxmOrderManager/exportXls',
          importExcelUrl: 'cxm/cxmOrderManager/importExcel'
        }
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      handleTableChange(){

      },
      getPrcingNum() {
        this.axios.get('http://192.168.7.206:9099/cxmsystem/sale/cxmSaleReceipt/list'
        ).then(res => {
          let rs = res.result
          console.log(res)
        }).catch(err => {
          // this.expRoute("2",err.message)
        })
      },
      getInfo(record) {
        this.$refs.cxmOrderManagerInfoModal.showDrawer(record)
      }
    },
    mounted() {
      this.getPrcingNum()
    },
    filters: {
      filterTime(time) {
        return moment(time).format('YYYY-MM-DD')
      },
      filterDepositAttribute(depositAttribute) {
        switch (depositAttribute) {
          case '1':
            return '可退'
            break
          case '2':
            return '不可退'
            break
          case '3':
            return '有条件可退'
            break
        }
      }
    }
  }
</script>
<style scoped>
  @import "~@assets/less/common.less";
</style>
